﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Mysoft.MyCM.Web.Controllers
{
    public class UserController : Controller
    {
        // GET: User
		public ActionResult Switch(string returnUrl)
		{
			return Redirect(
				string.Format("{0}/Login.aspx?action=sso&returnurl={1}",
				M.Web.Util.GetAppConfig("sso-server"),
				returnUrl));
		}

		// 简单实现用户信息，不写在业务处理类中
		#region 用户简单登陆校验
		/// <summary>
		/// 获取已登陆的用户信息
		/// </summary>
		/// <returns></returns>
		public static M.SSO.AuthUser GetLogonUser()
		{
			return (M.Web.Util.GetSession("MysoftCMLogonUser") == null) ?
				null :
				(M.SSO.AuthUser)M.Web.Util.GetSession("MysoftCMLogonUser");
		}
		/// <summary>
		/// 保存登陆用户信息
		/// </summary>
		/// <param name="logonUser"></param>
		public static void SaveLogonUser(M.SSO.AuthUser logonUser)
		{
			M.Web.Util.WriteSession("MysoftCMLogonUser", logonUser);
		}

		#endregion
    }
}